package com.youxuit.youxu.kecheng.threadPool;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class CallableTest implements Callable {
    @Override
    public Object call() throws Exception {
        return "i am callable!";
    }

    public static void main(String[] args) {
        //创建异步任务
        FutureTask<String> task = new FutureTask<String>(new CallableTest());
        //启动线程
        new Thread(task).start();

        try {
            String result = task.get();
            System.out.println(result);
        } catch (InterruptedException e) {
            e.printStackTrace();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }

    }
}
